package com.hiabr.iep.common.web.config;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

import java.io.IOException;

/**
 * @Author chenxudong
 **/

public class WebLongSerializer extends JsonSerializer<Long> {
    public static final WebLongSerializer instance = new WebLongSerializer();

    @Override
    public void serialize(Long value, JsonGenerator gen, SerializerProvider serializerProvider) throws IOException {
        if (null != value) {
            if (value > 9000000000000000L) {
                gen.writeString(value.toString());
            } else {
                gen.writeNumber(value);
            }
        }
    }
}
